package com.github.live.component;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;

import com.github.live.base.KeyEventDispatcher;

/**
 * @ClassName TvRecyclerView
 * @description:
 * @author: biao532
 * @create: 2024-01-04 14:47
 * @Version 1.0
 **/
public class KeyEventTvRecyclerView extends com.owen.tvrecyclerview.widget.TvRecyclerView {
    private KeyEventDispatcher dispatcher;
    public KeyEventTvRecyclerView(Context context) {
        super(context);
    }

    public KeyEventTvRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public KeyEventTvRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setKeyEventDispatcher(KeyEventDispatcher dispatcher) {
        this.dispatcher = dispatcher;
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (dispatcher != null && dispatcher.dispatch(event.getKeyCode(), event)) {
            return true;
        }
        return super.dispatchKeyEvent(event);
    }
}
